import 'dart:async';

import 'package:flutter/services.dart';

class UmengLinkPlugin {
  static const MethodChannel _channel =
      const MethodChannel('umeng_link_plugin');
  static bool _enablePasteboard;

  /// 获取ULink传参的方法
  static Future getUMLinkGetInstallParams() async {
    var value = await _channel.invokeMethod(
      'getUMLinkGetInstallParams',
      {"enablePasteboard": _enablePasteboard}, // enablePasteboard值仅在IOS中使用
    );
    print("UmengLinkPlugin value = $value");
    return value;
  }

  /// 注册安卓端ULink监听
  /// 添加是否使用剪切板模糊匹配
  static Future initUMHandleUMLinkURI({
    bool enablePasteboard = true,
  }) async {
    _enablePasteboard = enablePasteboard;
    var value = await _channel.invokeMethod(
        "initHandleUMLinkURI", {"enablePasteboard": enablePasteboard});
    return value;
  }

  /// 清掉安卓端保存的Link信息
  static Future cleanLinkParams() async {
    var value = await _channel.invokeMethod("cleanLinkParams");
    return value;
  }
}
